home *** CD-ROM | disk | FTP | other *** search
/ Aminet 7 / Aminet 7 - August 1995.iso / Aminet / docs / misc / ConcNews.lha / news / amiga.programming / comp.sys.amiga.programmer_4043_000022.msg < prev    next >
Encoding:
Internet Message Format  |  1994-11-27  |  4.9 KB

  1. Path: dd.chalmers.se!news.chalmers.se!sunic!EU.net!howland.reston.ans.net!xlink.net!wega.fibronics.de!pfm.PFM-Mainz.DE!babylon!rbabel
  2. From: rbabel@babylon.rmt.sub.org (Ralph Babel)
  3. Newsgroups: comp.sys.amiga.programmer,comp.sys.amiga.datacomm
  4. Subject: Re: The meaning of library base ptrs
  5. Message-ID: <15381@babylon.rmt.sub.org>
  6. Date: 12 Jan 1994 14:39:45 +0100
  7. Followup-To: comp.sys.amiga.programmer
  8. References: <CJ1JD1.Hwr@sugar.NeoSoft.COM> <zaphod.02vj@cayman.priconet.de> <rDT7u*ct5@aargh.adsp.sub.org> <thai0009.758159857@gold.tc.umn.edu>
  9. Lines: 96
  10. Xref: dd.chalmers.se comp.sys.amiga.programmer:4043 comp.sys.amiga.datacomm:2260
  11.  
  12. Douglas L Thain wrote:
  13.  
  14. > _every_ task/process is required to call OpenLibrary
  15. > explicitly, as per C= instructions.  This technique has
  16. > been incidentally valid on previous releases, but has
  17. > never been legal.
  18.  
  19. This is not true.
  20.  
  21. Up to and including 1.2, the official documentation never
  22. even mentioned that topic, and several of the example
  23. programs provided by Commodore and its engineers _did_ share
  24. library base pointers, so it was clearly _not_ required to
  25. reopen every library in a subtask.
  26.  
  27. As of Workbench 1.3, the only _exceptions_ (i.e. it was
  28. _still_ legal to share all _other_ libraries' base pointers)
  29. were the IEEE libraries, which Dale Luck had rewritten to
  30. support the 6888x and arbitrary other coprocessors (see [1,
  31. 2]). This did not really have anything to do with different
  32. library _bases_, though, but with the support for non-6888x
  33. coprocessors via the MathIEEE.resource, as Exec saves and
  34. restores the FPU context only for 6888x-compatible
  35. coprocessors automatically upon task switches. Dale
  36. suggested that the MathIEEE.resource patch tc_Switch and
  37. tc_Launch for that purpose (via the TaskOpenLib call-back).
  38.  
  39. Under 2.x, someone (who - as Hans put it - should probably
  40. be embarrassed :-) decided that unique library bases for
  41. every opener might be a useful concept (which I don't
  42. doubt), but made the mistake of declaring this the new
  43. default behavior (see [3]).
  44.  
  45. The problem lies not so much with application programs
  46. spawning new tasks, as these application subtasks generally
  47. make use of local per-task data anyway, and reopening all
  48. libraries and keeping their bases as part of that local data
  49. segment is trivial. It may be somewhat of a problem to make
  50. your high-level-language compiler automatically use these
  51. "local" base symbols, but this is completely beside the
  52. point.
  53.  
  54. The real problem lies with shared libraries (or devices)
  55. based on other shared libraries the functions of which are
  56. called on the schedule of the client of the higher-level
  57. library. If - as some people claim - _all_ "sub"-libraries
  58. have to be reopened for _every_ opener/client/task of the
  59. higher-level library, this requires that either
  60.  
  61. (a) all calls to lower-level libraries be deferred to a
  62.     global library task to ensure that the library base
  63.     obtained once during library initialization is used only
  64.     from the task that originally opened the library. This
  65.     would introduce two extra task switches for every
  66.     library call. Have fun!
  67.  
  68. (b) _All_ such libraries (and I really mean _all_ of them) -
  69.     even if they _don't_ require that any per-client data be
  70.     kept by the library itself - suddenly have to create and
  71.     return a new instance of the library base structure upon
  72.     every OpenLibrary() to hold the base addresses of all
  73.     libraries that are used by any of _its_ function
  74.     entries. (As somebody else already pointed out, this may
  75.     also cause problems with SetFunction().)
  76.  
  77. Neither of these two approaches seems desirable, so I
  78. maintain that the best solution would be to assume that all
  79. library base pointers - UNLESS EXPLICITLY DOCUMENTED NOT TO
  80. BE SHARABLE - _can_ be reused in subtasks. It may be
  81. unnecessary to depend on that assumption if one is merely
  82. writing application programs or SAS-style libraries, but for
  83. properly designed libraries/APIs that require that a context
  84. structure be allocated explicitly by the caller and freed
  85. upon exit, anything else doesn't make sense. This would have
  86. been possible for ixemul.library and socket.library, too,
  87. had they added an extra pointer parameter to (the internal
  88. versions of) all library functions. No-one said that this
  89. extra parameter would have to be visible externally; it may
  90. well be hidden inside a stub function that loads a global
  91. symbol into the appropriate parameter register, similar to
  92. the library base symbols in the amiga.lib stubs.
  93.  
  94. To cut a long story short: There's only _one_ solution:
  95. Library base pointers _must_ be sharable by _default_.
  96. _Exceptions_ to that rule are permissible, but must be
  97. documented as such explicitly.
  98.  
  99. Time to fix the RKMs.
  100.  
  101. References:
  102.  
  103. [1] RKM Libraries & Devices, 1.3 edition, page 547.
  104.  
  105. [2] AmigaMail, volume 1, pages XIII-5 to XIII-7.
  106.  
  107. [3] RKM Libraries, 2.0 edition, page 467.
  108.